Arduino meets MATLAB: Interfacing, Programs and Simulink by Singh Rajesh & Gehlot Anita & Singh Bhupendra & Choudhury Sushabhan
Author:Singh, Rajesh & Gehlot, Anita & Singh, Bhupendra & Choudhury, Sushabhan [Singh, Rajesh]
Language: eng
Format: azw3
ISBN: 9781681087283
Publisher: Bentham Science Publishers
Published: 2018-09-25T16:00:00+00:00
Fig. (5.11) shows circuit diagram for the interfacing of servo motor with Arduino.
Fig. (5.11))
Circuit diagram for the interfacing of servo motor with Arduino.
5.4.2. Program
#include <LiquidCrystal.h>
#include <Servo.h>
// initialize the library of LCD RS,E,D4,D5,D6,D7
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
lcd.begin(16, 2);// initialize the LCD
myservo.attach(3); // connect servo at pin3
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees(step of one degree)
{
lcd.clear();
myservo.write(pos); // tell servo to go to position in variable 'pos'
lcd.print(pos);// display position on LCD
delay(15); // delay 15ms
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
lcd.clear();
myservo.write(pos); // tell servo to go to position in variable 'pos'
lcd.print(pos);// display position on LCD
delay(15); // delay 15ms
}
}
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(27122)
Hello! Python by Anthony Briggs(25975)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(25313)
Kotlin in Action by Dmitry Jemerov(24417)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(23613)
Dependency Injection in .NET by Mark Seemann(23331)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21964)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20869)
Grails in Action by Glen Smith Peter Ledbrook(19889)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17084)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16850)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14477)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12600)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11877)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10657)
Hit Refresh by Satya Nadella(9258)
The Kubernetes Operator Framework Book by Michael Dame(8600)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8449)
Robo-Advisor with Python by Aki Ranin(8394)